package cn.blnp.net.flowable.boot.config.flowable;

import cn.blnp.net.flowable.boot.customer.flowable.validator.CustomValidator;
import lombok.extern.slf4j.Slf4j;
import org.flowable.validation.ProcessValidatorImpl;
import org.flowable.validation.validator.ValidatorSet;
import org.flowable.validation.validator.ValidatorSetFactory;
import org.springframework.context.annotation.Configuration;

/**
 * <h3>自定义流程校验器</h3>
 *
 * @author <a href="mailto:blnp.yibin@qq.com">lyb</a>
 * @version 1.0
 * @since 2025/6/9 11:31
 */
@Slf4j
@Configuration
public class CustomProcessValidator extends ProcessValidatorImpl {

    public CustomProcessValidator() {
        //加入Flowable默认的校验规则
        this.addValidatorSet(new ValidatorSetFactory().createFlowableExecutableProcessValidatorSet());
        //加入自定义的校验规则
        ValidatorSet customValidatorSet = new ValidatorSet("custom-validtor");
        customValidatorSet.addValidator(new CustomValidator());
        this.addValidatorSet(customValidatorSet);
    }
}
